
const express = require('express');
const request = require('request');
const router = express.Router();


/* GET signup page. */
router.get('/', function(req, res, next) {
  res.render('signup');
});

router.post('/', function(req, res, next) {    
    const url = 'http://userregister:5000/register'
    request({
        url: url,
        method: "POST",
        json: true,
        body: JSON.stringify(req.body)
    }, function(error, response, body){
        if(!error && response.statusCode == 200){
            res.redirect('signin')
        }
        else
        {
            res.send('Error, try again')
        }

    });
  });

module.exports = router;